<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LINE 1 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span id="local-6989586621679116970"></span><span>
</span><span id="line-1"></span><span class="hs-pragma">{-# LANGUAGE CPP #-}</span><span>
</span><span id="line-2"></span><span class="hs-comment">{- |
   Module      :  System.Win32.Info.Version
   Copyright   :  2013 shelarcy
   License     :  BSD-style

   Maintainer  :  shelarcy@gmail.com
   Stability   :  Provisional
   Portability :  Non-portable (Win32 API)

   Version information about your computer.
-}</span><span>
</span><span id="line-13"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">System.Win32.Info.Version</span><span>
</span><span id="line-14"></span><span>  </span><span class="hs-special">(</span><span> </span><span class="hs-comment">-- * Version Info</span><span>
</span><span id="line-15"></span><span>    </span><span class="hs-identifier">OSVERSIONINFOEX</span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">POSVERSIONINFOEX</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">LPOSVERSIONINFOEX</span><span>
</span><span id="line-16"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">ProductType</span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-17"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">getVersionEx</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">c_GetVersionEx</span><span>
</span><span id="line-18"></span><span>  </span><span>
</span><span id="line-19"></span><span>    </span><span class="hs-comment">-- * Verify OS version</span><span>
</span><span id="line-20"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">isVistaOrLater</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">is7OrLater</span><span>
</span><span id="line-21"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-22"></span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Ptr</span><span>           </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">Ptr</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">plusPtr</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Marshal.Alloc</span><span> </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">alloca</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">Foreign.Storable</span><span>      </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">Storable</span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-26"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.String</span><span>   </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">withTString</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">peekTString</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Types</span><span>    </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">BOOL</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">BYTE</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">System.Win32.Word</span><span>     </span><span class="hs-special">(</span><span> </span><span class="hs-identifier">WORD</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">DWORD</span><span> </span><span class="hs-special">)</span><span class="hs-cpp">



#include &quot;windows_cconv.h&quot;
</span><span>
</span><span id="line-34"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-35"></span><span class="hs-comment">-- Version Info</span><span>
</span><span id="line-36"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-37"></span><span class="hs-identifier">getVersionEx</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">OSVERSIONINFOEX</span><span>
</span><span id="line-38"></span><span class="hs-identifier">getVersionEx</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-39"></span><span>  </span><span class="hs-identifier">alloca</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-40"></span><span>    </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-41"></span><span class="hs-pragma">{-# LINE 41 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-41"></span><span>      </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">sizeOf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">undefined</span><span class="hs-glyph">::</span><span class="hs-identifier">OSVERSIONINFOEX</span><span class="hs-special">)</span><span>
</span><span id="line-42"></span><span>    </span><span class="hs-identifier">failIfFalse_</span><span> </span><span class="hs-string">&quot;GetVersionEx&quot;</span><span>
</span><span id="line-43"></span><span>      </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">c_GetVersionEx</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-44"></span><span>    </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">ProductType</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">VerUnknow</span><span> </span><span class="hs-identifier">BYTE</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">VerNTWorkStation</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">VerNTDomainControler</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-identifier">VerNTServer</span><span>
</span><span id="line-47"></span><span>    </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">Show</span><span class="hs-special">,</span><span class="hs-identifier">Eq</span><span class="hs-special">)</span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span class="hs-keyword">instance</span><span> </span><span class="hs-identifier">Storable</span><span> </span><span class="hs-identifier">ProductType</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-50"></span><span>    </span><span class="hs-identifier">sizeOf</span><span>    </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">sizeOf</span><span>    </span><span class="hs-special">(</span><span class="hs-identifier">undefined</span><span class="hs-glyph">::</span><span class="hs-identifier">BYTE</span><span class="hs-special">)</span><span>
</span><span id="line-51"></span><span>    </span><span class="hs-identifier">alignment</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">alignment</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">undefined</span><span class="hs-glyph">::</span><span class="hs-identifier">BYTE</span><span class="hs-special">)</span><span>
</span><span id="line-52"></span><span>    </span><span class="hs-identifier">poke</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">v</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">v</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-53"></span><span>        </span><span class="hs-identifier">VerUnknow</span><span> </span><span class="hs-identifier">w</span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">w</span><span>
</span><span id="line-54"></span><span>        </span><span class="hs-identifier">VerNTWorkStation</span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-number">1</span><span>
</span><span id="line-55"></span><span class="hs-pragma">{-# LINE 55 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-55"></span><span>        </span><span class="hs-identifier">VerNTDomainControler</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-number">2</span><span>
</span><span id="line-56"></span><span class="hs-pragma">{-# LINE 56 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-56"></span><span>        </span><span class="hs-identifier">VerNTServer</span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-number">3</span><span>
</span><span id="line-57"></span><span class="hs-pragma">{-# LINE 57 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-57"></span><span>    </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-58"></span><span>        </span><span class="hs-identifier">v</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-number">0</span><span>
</span><span id="line-59"></span><span>        </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-identifier">v</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-60"></span><span>            </span><span class="hs-special">(</span><span class="hs-number">1</span><span class="hs-special">)</span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">VerNTWorkStation</span><span>
</span><span id="line-61"></span><span class="hs-pragma">{-# LINE 61 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-61"></span><span>            </span><span class="hs-special">(</span><span class="hs-number">2</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">VerNTDomainControler</span><span>
</span><span id="line-62"></span><span class="hs-pragma">{-# LINE 62 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-62"></span><span>            </span><span class="hs-special">(</span><span class="hs-number">3</span><span class="hs-special">)</span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">VerNTServer</span><span>
</span><span id="line-63"></span><span class="hs-pragma">{-# LINE 63 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-63"></span><span>            </span><span class="hs-identifier">w</span><span>                                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">VerUnknow</span><span> </span><span class="hs-identifier">w</span><span>
</span><span id="line-64"></span><span>
</span><span id="line-65"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">POSVERSIONINFOEX</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">OSVERSIONINFOEX</span><span>
</span><span id="line-66"></span><span class="hs-keyword">type</span><span> </span><span class="hs-identifier">LPOSVERSIONINFOEX</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">Ptr</span><span> </span><span class="hs-identifier">OSVERSIONINFOEX</span><span>
</span><span id="line-67"></span><span>
</span><span id="line-68"></span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">OSVERSIONINFOEX</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">OSVERSIONINFOEX</span><span>
</span><span id="line-69"></span><span>     </span><span class="hs-special">{</span><span> </span><span class="hs-identifier">dwMajorVersion</span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-70"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">dwMinorVersion</span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-71"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">dwBuildNumber</span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-72"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">dwPlatformId</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">DWORD</span><span>
</span><span id="line-73"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">szCSDVersion</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">String</span><span>
</span><span id="line-74"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">wServicePackMajor</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WORD</span><span>
</span><span id="line-75"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">wServicePackMinor</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WORD</span><span>
</span><span id="line-76"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">wSuiteMask</span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">WORD</span><span>
</span><span id="line-77"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="hs-identifier">wProductType</span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">ProductType</span><span>
</span><span id="line-78"></span><span>     </span><span class="hs-special">}</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-identifier">Show</span><span>
</span><span id="line-79"></span><span>
</span><span id="line-80"></span><span class="hs-keyword">instance</span><span> </span><span class="hs-identifier">Storable</span><span> </span><span class="hs-identifier">OSVERSIONINFOEX</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-81"></span><span>    </span><span class="hs-identifier">sizeOf</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">const</span><span> </span><span class="hs-special">(</span><span class="hs-number">284</span><span class="hs-special">)</span><span>
</span><span id="line-82"></span><span class="hs-pragma">{-# LINE 82 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-82"></span><span>    </span><span class="hs-identifier">alignment</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-number">4</span><span>
</span><span id="line-83"></span><span class="hs-pragma">{-# LINE 83 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-83"></span><span>    </span><span class="hs-identifier">poke</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">info</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-84"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">0</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">sizeOf</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span>
</span><span id="line-85"></span><span class="hs-pragma">{-# LINE 85 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-85"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">4</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">dwMajorVersion</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span>
</span><span id="line-86"></span><span class="hs-pragma">{-# LINE 86 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-86"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">8</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">dwMinorVersion</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span>
</span><span id="line-87"></span><span class="hs-pragma">{-# LINE 87 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-87"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">12</span><span class="hs-special">)</span><span class="hs-special">)</span><span>  </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">dwBuildNumber</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span>
</span><span id="line-88"></span><span class="hs-pragma">{-# LINE 88 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-88"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">16</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">dwPlatformId</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span>
</span><span id="line-89"></span><span class="hs-pragma">{-# LINE 89 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-89"></span><span>        </span><span class="hs-identifier">withTString</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">szCSDVersion</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-glyph">\</span><span class="hs-identifier">szCSDVersion'</span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-90"></span><span>          </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">20</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-identifier">szCSDVersion'</span><span>
</span><span id="line-91"></span><span class="hs-pragma">{-# LINE 91 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-91"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">276</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">wServicePackMajor</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span>
</span><span id="line-92"></span><span class="hs-pragma">{-# LINE 92 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-92"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">278</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">wServicePackMinor</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span>
</span><span id="line-93"></span><span class="hs-pragma">{-# LINE 93 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-93"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">280</span><span class="hs-special">)</span><span class="hs-special">)</span><span>   </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">wSuiteMask</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span>
</span><span id="line-94"></span><span class="hs-pragma">{-# LINE 94 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-94"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">282</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-identifier">wProductType</span><span> </span><span class="hs-identifier">info</span><span class="hs-special">)</span><span>
</span><span id="line-95"></span><span class="hs-pragma">{-# LINE 95 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-95"></span><span>        </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">pokeByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">283</span><span class="hs-special">)</span><span class="hs-special">)</span><span>    </span><span class="hs-identifier">buf</span><span> </span><span class="hs-special">(</span><span class="hs-number">0</span><span class="hs-glyph">::</span><span class="hs-identifier">BYTE</span><span class="hs-special">)</span><span>
</span><span id="line-96"></span><span class="hs-pragma">{-# LINE 96 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-96"></span><span>
</span><span id="line-97"></span><span>    </span><span class="hs-identifier">peek</span><span> </span><span class="hs-identifier">buf</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-98"></span><span>        </span><span class="hs-identifier">majorVersion</span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">4</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-99"></span><span class="hs-pragma">{-# LINE 99 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-99"></span><span>        </span><span class="hs-identifier">minorVersion</span><span>     </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">8</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-100"></span><span class="hs-pragma">{-# LINE 100 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-100"></span><span>        </span><span class="hs-identifier">buildNumber</span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">12</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-101"></span><span class="hs-pragma">{-# LINE 101 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-101"></span><span>        </span><span class="hs-identifier">platformId</span><span>       </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">16</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-102"></span><span class="hs-pragma">{-# LINE 102 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-102"></span><span>        </span><span class="hs-identifier">cSDVersion</span><span>       </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">peekTString</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-special">`</span><span class="hs-identifier">plusPtr</span><span class="hs-special">`</span><span> </span><span class="hs-number">20</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-103"></span><span class="hs-pragma">{-# LINE 103 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-103"></span><span>        </span><span class="hs-identifier">servicePackMajor</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">276</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-104"></span><span class="hs-pragma">{-# LINE 104 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-104"></span><span>        </span><span class="hs-identifier">servicePackMinor</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">278</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-105"></span><span class="hs-pragma">{-# LINE 105 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-105"></span><span>        </span><span class="hs-identifier">suiteMask</span><span>        </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">280</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-106"></span><span class="hs-pragma">{-# LINE 106 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-106"></span><span>        </span><span class="hs-identifier">productType</span><span>      </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">peekByteOff</span><span> </span><span class="hs-identifier">hsc_ptr</span><span> </span><span class="hs-number">282</span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-identifier">buf</span><span>
</span><span id="line-107"></span><span class="hs-pragma">{-# LINE 107 &quot;libraries\\Win32\\System\\Win32\\Info\\Version.hsc&quot; #-}</span><span>
</span><span id="line-107"></span><span>        </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-identifier">OSVERSIONINFOEX</span><span> </span><span class="hs-identifier">majorVersion</span><span> </span><span class="hs-identifier">minorVersion</span><span>
</span><span id="line-108"></span><span>                                 </span><span class="hs-identifier">buildNumber</span><span> </span><span class="hs-identifier">platformId</span><span> </span><span class="hs-identifier">cSDVersion</span><span>
</span><span id="line-109"></span><span>                                 </span><span class="hs-identifier">servicePackMajor</span><span> </span><span class="hs-identifier">servicePackMinor</span><span>
</span><span id="line-110"></span><span>                                 </span><span class="hs-identifier">suiteMask</span><span> </span><span class="hs-identifier">productType</span><span>
</span><span id="line-111"></span><span>
</span><span id="line-112"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="hs-identifier">WINDOWS_CCONV</span><span> </span><span class="hs-keyword">unsafe</span><span> </span><span class="hs-string">&quot;windows.h GetVersionExW&quot;</span><span>
</span><span id="line-113"></span><span>  </span><span class="hs-identifier">c_GetVersionEx</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">LPOSVERSIONINFOEX</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">BOOL</span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-116"></span><span class="hs-comment">-- Verify OS version</span><span>
</span><span id="line-117"></span><span class="hs-comment">----------------------------------------------------------------</span><span>
</span><span id="line-118"></span><span class="hs-comment">-- See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724833(v=vs.85).aspx</span><span>
</span><span id="line-119"></span><span>
</span><span id="line-120"></span><span class="hs-identifier">isVistaOrLater</span><span class="hs-special">,</span><span> </span><span class="hs-identifier">is7OrLater</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-identifier">IO</span><span> </span><span class="hs-identifier">Bool</span><span>
</span><span id="line-121"></span><span class="hs-identifier">isVistaOrLater</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-122"></span><span>  </span><span class="hs-identifier">ver</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">getVersionEx</span><span>
</span><span id="line-123"></span><span>  </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span> </span><span class="hs-number">6</span><span> </span><span class="hs-operator">&lt;=</span><span> </span><span class="hs-identifier">dwMajorVersion</span><span> </span><span class="hs-identifier">ver</span><span>
</span><span id="line-124"></span><span>
</span><span id="line-125"></span><span class="hs-identifier">is7OrLater</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-126"></span><span>  </span><span class="hs-identifier">ver</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-identifier">getVersionEx</span><span>
</span><span id="line-127"></span><span>  </span><span class="hs-identifier">return</span><span> </span><span class="hs-operator">$</span><span>  </span><span class="hs-number">6</span><span> </span><span class="hs-operator">&lt;=</span><span> </span><span class="hs-identifier">dwMajorVersion</span><span> </span><span class="hs-identifier">ver</span><span>
</span><span id="line-128"></span><span>         </span><span class="hs-operator">&amp;&amp;</span><span> </span><span class="hs-number">1</span><span> </span><span class="hs-operator">&lt;=</span><span> </span><span class="hs-identifier">dwMinorVersion</span><span> </span><span class="hs-identifier">ver</span><span>
</span><span id="line-129"></span><span>
</span><span id="line-130"></span><span class="hs-comment">{-
We don't use VerifyVersionInfo function to above functions.

Because VerifyVersionInfo is more difficult than GetVersionEx and accessing field in Haskell.

-- | See: http://support.microsoft.com/kb/225013/
-- http://msdn.microsoft.com/en-us/library/windows/desktop/ms725491(v=vs.85).aspx

bIsWindowsVersionOK :: DWORD -&gt; DWORD -&gt; WORD -&gt; IO BOOL
bIsWindowsVersionOK dwMajor dwMinor dwSPMajor =
  alloca $ \buf -&gt; do
    zeroMemory buf
      (#{size OSVERSIONINFOEXW}::DWORD)
    (#poke OSVERSIONINFOEXW, dwOSVersionInfoSize) buf
      (#{size OSVERSIONINFOEXW}::DWORD)
    (#poke OSVERSIONINFOEXW, dwMajorVersion)    buf dwMajor
    (#poke OSVERSIONINFOEXW, dwMinorVersion)    buf dwMinor
    (#poke OSVERSIONINFOEXW, wServicePackMajor) buf dwSPMajor
    --  Set up the condition mask.
    let dwlConditionMask = 0
        flag =    #const VER_MAJORVERSION
             .|.  #const VER_MINORVERSION
             .|.  #const VER_SERVICEPACKMAJOR
    dwlConditionMask'   &lt;- vER_SET_CONDITION dwlConditionMask   #{const VER_MAJORVERSION} #{const VER_GREATER_EQUAL}
    dwlConditionMask''  &lt;- vER_SET_CONDITION dwlConditionMask'  #{const VER_MINORVERSION} #{const VER_MINORVERSION}
    dwlConditionMask''' &lt;- vER_SET_CONDITION dwlConditionMask'' #{const VER_SERVICEPACKMAJOR} #{const VER_SERVICEPACKMAJOR}
    verifyVersionInfo buf flag dwlConditionMask'''

type ULONGLONG = DWORDLONG

foreign import capi unsafe &quot;windows.h VER_SET_CONDITION&quot;
  vER_SET_CONDITION :: ULONGLONG -&gt; DWORD -&gt; BYTE -&gt; IO ULONGLONG

foreign import WINDOWS_CCONV unsafe &quot;windows.h VerifyVersionInfoW&quot;
  verifyVersionInfo :: LPOSVERSIONINFOEX -&gt; DWORD -&gt; DWORDLONG -&gt; IO BOOL
-}</span><span>
</span><span id="line-166"></span></pre></body></html>